function onPageReady() {
    try {
        $('.filter-panel').css('margin-top', plus.navigator.getStatusbarHeight() * 2 + 'px');
    } catch (e) {
    }
    var filter = [
        {
            name: '区域', children: [{
                "id": "581",
                "city_code": "[]",
                "ad_code": "220000",
                "name": "吉林省",
                "center": "125.3245,43.886841",
                "level": "province",
                "parent_id": "1",
                "son": "1",
                "children": [{
                    "id": "582",
                    "city_code": "0431",
                    "ad_code": "220100",
                    "name": "长春市",
                    "center": "125.3245,43.886841",
                    "level": "city",
                    "parent_id": "581",
                    "son": "1",
                    "children": [{
                        "id": "220102",
                        "city_code": "0431",
                        "ad_code": "220102",
                        "name": "南关区",
                        "center": "125.337237,43.890235",
                        "level": "district",
                        "parent_id": "582",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220103",
                        "city_code": "0431",
                        "ad_code": "220103",
                        "name": "宽城区",
                        "center": "125.342828,43.903823",
                        "level": "district",
                        "parent_id": "582",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220104",
                        "city_code": "0431",
                        "ad_code": "220104",
                        "name": "朝阳区",
                        "center": "125.318042,43.86491",
                        "level": "district",
                        "parent_id": "582",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220105",
                        "city_code": "0431",
                        "ad_code": "220105",
                        "name": "二道区",
                        "center": "125.384727,43.870824",
                        "level": "district",
                        "parent_id": "582",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220106",
                        "city_code": "0431",
                        "ad_code": "220106",
                        "name": "绿园区",
                        "center": "125.272467,43.892177",
                        "level": "district",
                        "parent_id": "582",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220112",
                        "city_code": "0431",
                        "ad_code": "220112",
                        "name": "双阳区",
                        "center": "125.659018,43.525168",
                        "level": "district",
                        "parent_id": "582",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220113",
                        "city_code": "0431",
                        "ad_code": "220113",
                        "name": "九台区",
                        "center": "125.844682,44.157155",
                        "level": "district",
                        "parent_id": "582",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220122",
                        "city_code": "0431",
                        "ad_code": "220122",
                        "name": "农安县",
                        "center": "125.175287,44.431258",
                        "level": "district",
                        "parent_id": "582",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220182",
                        "city_code": "0431",
                        "ad_code": "220182",
                        "name": "榆树市",
                        "center": "126.550107,44.827642",
                        "level": "district",
                        "parent_id": "582",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220183",
                        "city_code": "0431",
                        "ad_code": "220183",
                        "name": "德惠市",
                        "center": "125.703327,44.533909",
                        "level": "district",
                        "parent_id": "582",
                        "son": "1",
                        "children": []
                    }]
                }, {
                    "id": "593",
                    "city_code": "0432",
                    "ad_code": "220200",
                    "name": "吉林市",
                    "center": "126.55302,43.843577",
                    "level": "city",
                    "parent_id": "581",
                    "son": "1",
                    "children": [{
                        "id": "220202",
                        "city_code": "0432",
                        "ad_code": "220202",
                        "name": "昌邑区",
                        "center": "126.570766,43.851118",
                        "level": "district",
                        "parent_id": "593",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220203",
                        "city_code": "0432",
                        "ad_code": "220203",
                        "name": "龙潭区",
                        "center": "126.561429,43.909755",
                        "level": "district",
                        "parent_id": "593",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220204",
                        "city_code": "0432",
                        "ad_code": "220204",
                        "name": "船营区",
                        "center": "126.55239,43.843804",
                        "level": "district",
                        "parent_id": "593",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220211",
                        "city_code": "0432",
                        "ad_code": "220211",
                        "name": "丰满区",
                        "center": "126.560759,43.816594",
                        "level": "district",
                        "parent_id": "593",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220221",
                        "city_code": "0432",
                        "ad_code": "220221",
                        "name": "永吉县",
                        "center": "126.501622,43.667416",
                        "level": "district",
                        "parent_id": "593",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220281",
                        "city_code": "0432",
                        "ad_code": "220281",
                        "name": "蛟河市",
                        "center": "127.342739,43.720579",
                        "level": "district",
                        "parent_id": "593",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220282",
                        "city_code": "0432",
                        "ad_code": "220282",
                        "name": "桦甸市",
                        "center": "126.745445,42.972093",
                        "level": "district",
                        "parent_id": "593",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220283",
                        "city_code": "0432",
                        "ad_code": "220283",
                        "name": "舒兰市",
                        "center": "126.947813,44.410906",
                        "level": "district",
                        "parent_id": "593",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220284",
                        "city_code": "0432",
                        "ad_code": "220284",
                        "name": "磐石市",
                        "center": "126.059929,42.942476",
                        "level": "district",
                        "parent_id": "593",
                        "son": "1",
                        "children": []
                    }]
                }, {
                    "id": "603",
                    "city_code": "0434",
                    "ad_code": "220300",
                    "name": "四平市",
                    "center": "124.370785,43.170344",
                    "level": "city",
                    "parent_id": "581",
                    "son": "1",
                    "children": [{
                        "id": "220302",
                        "city_code": "0434",
                        "ad_code": "220302",
                        "name": "铁西区",
                        "center": "124.360894,43.176263",
                        "level": "district",
                        "parent_id": "603",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220303",
                        "city_code": "0434",
                        "ad_code": "220303",
                        "name": "铁东区",
                        "center": "124.388464,43.16726",
                        "level": "district",
                        "parent_id": "603",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220322",
                        "city_code": "0434",
                        "ad_code": "220322",
                        "name": "梨树县",
                        "center": "124.335802,43.30831",
                        "level": "district",
                        "parent_id": "603",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220323",
                        "city_code": "0434",
                        "ad_code": "220323",
                        "name": "伊通满族自治县",
                        "center": "125.303124,43.345464",
                        "level": "district",
                        "parent_id": "603",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220381",
                        "city_code": "0434",
                        "ad_code": "220381",
                        "name": "公主岭市",
                        "center": "124.817588,43.509474",
                        "level": "district",
                        "parent_id": "603",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220382",
                        "city_code": "0434",
                        "ad_code": "220382",
                        "name": "双辽市",
                        "center": "123.505283,43.518275",
                        "level": "district",
                        "parent_id": "603",
                        "son": "1",
                        "children": []
                    }]
                }, {
                    "id": "610",
                    "city_code": "0437",
                    "ad_code": "220400",
                    "name": "辽源市",
                    "center": "125.145349,42.902692",
                    "level": "city",
                    "parent_id": "581",
                    "son": "1",
                    "children": [{
                        "id": "220402",
                        "city_code": "0437",
                        "ad_code": "220402",
                        "name": "龙山区",
                        "center": "125.145164,42.902702",
                        "level": "district",
                        "parent_id": "610",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220403",
                        "city_code": "0437",
                        "ad_code": "220403",
                        "name": "西安区",
                        "center": "125.151424,42.920415",
                        "level": "district",
                        "parent_id": "610",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220421",
                        "city_code": "0437",
                        "ad_code": "220421",
                        "name": "东丰县",
                        "center": "125.529623,42.675228",
                        "level": "district",
                        "parent_id": "610",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220422",
                        "city_code": "0437",
                        "ad_code": "220422",
                        "name": "东辽县",
                        "center": "124.991995,42.927724",
                        "level": "district",
                        "parent_id": "610",
                        "son": "1",
                        "children": []
                    }]
                }, {
                    "id": "615",
                    "city_code": "0435",
                    "ad_code": "220500",
                    "name": "通化市",
                    "center": "125.936501,41.721177",
                    "level": "city",
                    "parent_id": "581",
                    "son": "1",
                    "children": [{
                        "id": "220502",
                        "city_code": "0435",
                        "ad_code": "220502",
                        "name": "东昌区",
                        "center": "125.936716,41.721233",
                        "level": "district",
                        "parent_id": "615",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220503",
                        "city_code": "0435",
                        "ad_code": "220503",
                        "name": "二道江区",
                        "center": "126.045987,41.777564",
                        "level": "district",
                        "parent_id": "615",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220521",
                        "city_code": "0435",
                        "ad_code": "220521",
                        "name": "通化县",
                        "center": "125.753121,41.677918",
                        "level": "district",
                        "parent_id": "615",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220523",
                        "city_code": "0435",
                        "ad_code": "220523",
                        "name": "辉南县",
                        "center": "126.042821,42.683459",
                        "level": "district",
                        "parent_id": "615",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220524",
                        "city_code": "0435",
                        "ad_code": "220524",
                        "name": "柳河县",
                        "center": "125.740536,42.281484",
                        "level": "district",
                        "parent_id": "615",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220581",
                        "city_code": "0435",
                        "ad_code": "220581",
                        "name": "梅河口市",
                        "center": "125.687336,42.530002",
                        "level": "district",
                        "parent_id": "615",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220582",
                        "city_code": "0435",
                        "ad_code": "220582",
                        "name": "集安市",
                        "center": "126.186204,41.126276",
                        "level": "district",
                        "parent_id": "615",
                        "son": "1",
                        "children": []
                    }]
                }, {
                    "id": "623",
                    "city_code": "0439",
                    "ad_code": "220600",
                    "name": "白山市",
                    "center": "126.427839,41.942505",
                    "level": "city",
                    "parent_id": "581",
                    "son": "1",
                    "children": [{
                        "id": "220602",
                        "city_code": "0439",
                        "ad_code": "220602",
                        "name": "浑江区",
                        "center": "126.428035,41.943065",
                        "level": "district",
                        "parent_id": "623",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220605",
                        "city_code": "0439",
                        "ad_code": "220605",
                        "name": "江源区",
                        "center": "126.584229,42.048109",
                        "level": "district",
                        "parent_id": "623",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220621",
                        "city_code": "0439",
                        "ad_code": "220621",
                        "name": "抚松县",
                        "center": "127.273796,42.332643",
                        "level": "district",
                        "parent_id": "623",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220622",
                        "city_code": "0439",
                        "ad_code": "220622",
                        "name": "靖宇县",
                        "center": "126.808386,42.389689",
                        "level": "district",
                        "parent_id": "623",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220623",
                        "city_code": "0439",
                        "ad_code": "220623",
                        "name": "长白朝鲜族自治县",
                        "center": "128.203384,41.419361",
                        "level": "district",
                        "parent_id": "623",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220681",
                        "city_code": "0439",
                        "ad_code": "220681",
                        "name": "临江市",
                        "center": "126.919296,41.810689",
                        "level": "district",
                        "parent_id": "623",
                        "son": "1",
                        "children": []
                    }]
                }, {
                    "id": "630",
                    "city_code": "0438",
                    "ad_code": "220700",
                    "name": "松原市",
                    "center": "124.823608,45.118243",
                    "level": "city",
                    "parent_id": "581",
                    "son": "1",
                    "children": [{
                        "id": "220702",
                        "city_code": "0438",
                        "ad_code": "220702",
                        "name": "宁江区",
                        "center": "124.827851,45.176498",
                        "level": "district",
                        "parent_id": "630",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220721",
                        "city_code": "0438",
                        "ad_code": "220721",
                        "name": "前郭尔罗斯蒙古族自治县",
                        "center": "124.826808,45.116288",
                        "level": "district",
                        "parent_id": "630",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220722",
                        "city_code": "0438",
                        "ad_code": "220722",
                        "name": "长岭县",
                        "center": "123.985184,44.276579",
                        "level": "district",
                        "parent_id": "630",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220723",
                        "city_code": "0438",
                        "ad_code": "220723",
                        "name": "乾安县",
                        "center": "124.024361,45.006846",
                        "level": "district",
                        "parent_id": "630",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220781",
                        "city_code": "0438",
                        "ad_code": "220781",
                        "name": "扶余市",
                        "center": "126.042758,44.986199",
                        "level": "district",
                        "parent_id": "630",
                        "son": "1",
                        "children": []
                    }]
                }, {
                    "id": "636",
                    "city_code": "0436",
                    "ad_code": "220800",
                    "name": "白城市",
                    "center": "122.841114,45.619026",
                    "level": "city",
                    "parent_id": "581",
                    "son": "1",
                    "children": [{
                        "id": "220802",
                        "city_code": "0436",
                        "ad_code": "220802",
                        "name": "洮北区",
                        "center": "122.842499,45.619253",
                        "level": "district",
                        "parent_id": "636",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220821",
                        "city_code": "0436",
                        "ad_code": "220821",
                        "name": "镇赉县",
                        "center": "123.202246,45.846089",
                        "level": "district",
                        "parent_id": "636",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220822",
                        "city_code": "0436",
                        "ad_code": "220822",
                        "name": "通榆县",
                        "center": "123.088543,44.80915",
                        "level": "district",
                        "parent_id": "636",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220881",
                        "city_code": "0436",
                        "ad_code": "220881",
                        "name": "洮南市",
                        "center": "122.783779,45.339113",
                        "level": "district",
                        "parent_id": "636",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "220882",
                        "city_code": "0436",
                        "ad_code": "220882",
                        "name": "大安市",
                        "center": "124.291512,45.507648",
                        "level": "district",
                        "parent_id": "636",
                        "son": "1",
                        "children": []
                    }]
                }, {
                    "id": "642",
                    "city_code": "1433",
                    "ad_code": "222400",
                    "name": "延边朝鲜族自治州",
                    "center": "129.513228,42.904823",
                    "level": "city",
                    "parent_id": "581",
                    "son": "1",
                    "children": [{
                        "id": "222401",
                        "city_code": "1433",
                        "ad_code": "222401",
                        "name": "延吉市",
                        "center": "129.51579,42.906964",
                        "level": "district",
                        "parent_id": "642",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "222402",
                        "city_code": "1433",
                        "ad_code": "222402",
                        "name": "图们市",
                        "center": "129.846701,42.966621",
                        "level": "district",
                        "parent_id": "642",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "222403",
                        "city_code": "1433",
                        "ad_code": "222403",
                        "name": "敦化市",
                        "center": "128.22986,43.366921",
                        "level": "district",
                        "parent_id": "642",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "222404",
                        "city_code": "1433",
                        "ad_code": "222404",
                        "name": "珲春市",
                        "center": "130.365787,42.871057",
                        "level": "district",
                        "parent_id": "642",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "222405",
                        "city_code": "1433",
                        "ad_code": "222405",
                        "name": "龙井市",
                        "center": "129.425747,42.771029",
                        "level": "district",
                        "parent_id": "642",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "222406",
                        "city_code": "1433",
                        "ad_code": "222406",
                        "name": "和龙市",
                        "center": "129.008748,42.547004",
                        "level": "district",
                        "parent_id": "642",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "222424",
                        "city_code": "1433",
                        "ad_code": "222424",
                        "name": "汪清县",
                        "center": "129.766161,43.315426",
                        "level": "district",
                        "parent_id": "642",
                        "son": "1",
                        "children": []
                    }, {
                        "id": "222426",
                        "city_code": "1433",
                        "ad_code": "222426",
                        "name": "安图县",
                        "center": "128.901865,43.110994",
                        "level": "district",
                        "parent_id": "642",
                        "son": "1",
                        "children": []
                    }]
                }]
            }]
        },
        {
            name: '部门', children: [
                {id: 1, name: '发改'},
                {id: 2, name: '工信'},
                {id: 3, name: '商务'},
                {id: 4, name: '科技'},
                {id: 5, name: '人社'},
                {id: 6, name: '农委'}
            ]
        },
        {
            name: '时限', children: [
                {id: 18, name: '2018年'},
                {id: 17, name: '2017年'},
                {id: 16, name: '2016年'},
                {id: 15, name: '2015年'},
                {id: 14, name: '2014年'},
                {id: 13, name: '2013年'},
                {id: 12, name: '2012年'},
                {id: 11, name: '2011年'},
                {id: 10, name: '2010年'},
                {id: 9, name: '2009年'},
                {id: 8, name: '2008年'},
                {id: 7, name: '2007年'},
                {id: 6, name: '2006年'},
                {id: 5, name: '2005年'},
                {id: 4, name: '2004年'},
                {id: 3, name: '2003年'},
                {id: 2, name: '2002年'},
                {id: 1, name: '2001年'}
            ]
        },
        {
            name: '类别', children: [
                {id: 1, name: '科技发展基础计划'},
                {id: 2, name: '科技发展引导计划'}
            ]
        },
        {
            name: '领域', children: [
                {id: 1, name: '大数据与云计算'},
                {id: 2, name: '医药生物'}
            ]
        }
    ];
    var $panel = $('.filter-panel');
    var select = [];
    $('.filter-bar>div').on('click', function () {
        var $this = $(this);
        if ($this.is('.active')) {
            $panel.hide();
        } else {
            if (!select.length || select[0] != $this.index()) {
                if ($this.attr('data-select')) {
                    select = $this.attr('data-select').split('-');
                } else {
                    select = [$this.index()];
                }
            }
            show();
            $('.filter-bar>div').removeClass('active');
            $panel.css('display', 'flex');
        }
        $this.toggleClass('active');
    });

    $('.filter-panel>div:nth-child(2)').on('click', function () {
        $('.filter-bar>div').removeClass('active');
        $panel.hide();
    });

    $panel.on('click', 'li', function () {
        select = $(this).attr('data-select').split('-');
        var list = filter[select[0]].children;
        var name = filter[select[0]].name;
        for (var i = 1; i < select.length; i++) {
            name = list[select[i]].name || name;
            list = list[select[i]].children;
        }
        if (list && list.length && select.length > 1) {
            show();
        } else {
            $('.filter-bar>div.active').html('<span class="lib-flex-1">' + name + '</span><div></div>').attr('data-select', $(this).attr('data-select')).attr('data-id', $(this).attr('data-id'));
            $('.filter-bar>div').removeClass('active');
            $panel.hide();
            onSearch();
        }
    });

    function show() {
        var list = filter[select[0]].children, flag, active, pre = '';
        var $target = $('.filter-panel>div:nth-child(1)');
        $target.empty();
        for (var i = 0; i < select.length; i++) {
            pre += select[i] + '-';
            list && list.length && $target.render('#filter-column', {});
            flag = false;
            for (var j = 0; list && j < list.length; j++) {
                if (select[i + 1] == j) {
                    flag = j;
                }
                $target.children('div:last-child').find('ul').append('<li class="' + (select[i + 1] == j ? 'active ' : '') + 'lib-flex-row-start-center" data-select="' + pre + j + '" data-id="' + list[j].id + '">' + list[j].name + '</li>');
            }
            if (i === 0) {
                $target.children('div:last-child').find('ul').append('<li class="lib-flex-row-start-center" data-select="' + select[0] + '" data-id="">清空</li>');
            }
            list = flag === false ? [] : list[flag].children;
        }
    }

    $(".title span").html("读&nbsp;政&nbsp;策");
    var page = initPage(".scroll-container", ".scroll-item", ".list", {
        url: "/api/home/getPolicyList",
        type: "get",
        dataType: "json",
        headers: {},
        data: new Page({orderType: "DESC"}),
        success: function (result) {
            for (var i in result.data) {
                var item = new PolicyBean(result.data[i]);
                item.title = item.title.replace(new RegExp($('.search-input').val(), 'g'), '<span>' + $('.search-input').val() + '</span>');
                $(".list").render("#item", item, "append");
                page.setLastRecordId(item.id);
            }
        }
    });

    function onSearch() {
        var city = ($('#city').attr('data-select')).split('-'), id = $('#city').attr('data-id'),
            departId = $('#departId').attr('data-id') || '',
            year = $('#year').attr('data-id') || '',
            category = $('#category').attr('data-id') || '',
            scope = $('#scope').attr('data-id') || '', provinceId, cityId, districtId;
        switch (city.length) {
            case 2: {
                provinceId = id;
                break;
            }
            case 3: {
                cityId = id;
                break;
            }
            case 4: {
                districtId = id;
                break;
            }
        }
        try {
            page.refresh({
                keyWords: $('.search-input').val(),
                departId: departId,
                year: year,
                category: category,
                scope: scope,
                provinceId: provinceId || '',
                cityId: cityId || '',
                districtId: districtId || ''
            });
        } catch (e) {
        }
    }
    $('.search-btn').on('click', function () {
        onSearch();
        $('.filter-bar>div').removeClass('active');
        $panel.hide();
    });
    $('.clean-btn').on('click', function () {
        var $this = $(this);
        $this.removeClass('js_show');
        $this.parent().find('input').val('').focus();
        onSearch();
    });
    $(document).keydown(function (event) {
        if (event.keyCode === 13) {
            onSearch();
            $('.filter-bar>div').removeClass('active');
            $panel.hide();
        }
    });
    $(document).on('click', function (event) {
        var $target = $(event.target);
        $('.clean.js_show').removeClass('js_show');
        if ($target.is('.clean-btn') && $target.parent().is('.input-cleanable')) {
            $target.parent().find('input').val('').focus();
            onSearch();
            $target.removeClass('js_show');
        } else if ($target.parent().is('.input-cleanable')) {
            if ($target.parent().find('input').val()) {
                $target.parent().find('.clean-btn').addClass('js_show');
            } else {
                $target.parent().find('.clean-btn').removeClass('js_show');
            }
        }
    });
    $(document).on('input', '.input-cleanable input', function () {
        var $this = $(this);
        if ($this.val()) {
            $this.parent().find('.clean-btn').addClass('js_show');
        } else {
            $this.parent().find('.clean-btn').removeClass('js_show');
        }
    });
}